﻿#pragma once

#ifndef ARD_ASYNCMANAGER_H
#define ARD_ASYNCMANAGER_H

#include <Common.h>
#include <core/Module.h>

/// <summary>
/// 携程调度管理器
/// </summary>
class AsyncManager
{
private:
    static AsyncManager* singleton;
    AsyncManager();
    // 不希望线程池对象进行拷贝构造和赋值
    AsyncManager(const AsyncManager& s) = default;
    AsyncManager& operator=(const AsyncManager& s) = default;
    ~AsyncManager();
    std::unordered_map<int, std::unique_ptr<Module>> _modules;// 模块map
    bool asyncLoop();
public:
    static AsyncManager* getInstance();
    //调度器算法，选择下一个运行的协程,在线程中处理
    static void SchedulerNext(AsyncManager* singleton);
    void init();
};

#endif // !ARD_ASYNCMANAGER_H